package com.hgy.controller;

import com.hgy.common.JsonResult;
import com.hgy.entity.City;
import com.hgy.service.CityService;
import com.hgy.vo.VCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author : ang
 * @Program: carSystem
 * @Title : CityController
 * @Date : 2020-08-27 14:38
 **/
@Controller
@RequestMapping("/city")
public class CityController {

    @Autowired
    private CityService cityService;

    @RequestMapping("/select.do")
    @ResponseBody
    public JsonResult findCity(Integer pid) {
        List<City> city = cityService.findCity(pid);
        return new JsonResult(1, city);
    }

    @RequestMapping("/citys.do")
    @ResponseBody
    public JsonResult selectCitys(Integer getid, Integer backid) {
        JsonResult jsonResult = null;
        try {
            VCity city = cityService.findById(getid, backid);
            jsonResult = new JsonResult(1,city);
        } catch (Exception e) {
            jsonResult = new JsonResult(1,e.getMessage());
        }
        return jsonResult;
    }

    /*@RequestMapping("findcar.do")
    @ResponseBody*/

}
